import java.util.*;

public class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
        //对字符串每个字符按字典序排序
        //放入map
        //
        Map<String, ArrayList> map=new HashMap<>();

        for(String s:strs){

        char[] temp=s.toCharArray();
        Arrays.sort(temp);
        String strKey=new String(temp);
        if(!map.containsKey(strKey)){
        map.put(strKey,new ArrayList());
        }
        map.get(strKey).add(s);
        }
        return new ArrayList(map.values());

        }
        }